package com.wunong.smart.collection.domain.state;

import com.wunong.smart.collection.application.context.CollectionContext;
import com.wunong.smart.collection.application.request.BaseCollectionRequest;
import com.wunong.smart.collection.domain.model.CollectionDomain;
import com.wunong.smart.collection.domain.state.operation.CollectionOperationFactory;

/**
 * @author create by zealot.zt
 */
public abstract class AbstractCollectionState implements CollectionState {

    @SuppressWarnings("unchecked")
    @Override
    public Object operate(BaseCollectionRequest request, CollectionDomain domain) {
        // 构建新的请求对象
        CollectionContext<BaseCollectionRequest> context = CollectionContext.of(request, domain);

        // 执行对应的操作
        return CollectionOperationFactory.getOperation(request).operate(context);
    }

}
